<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 
  Date: 2022/4/4
  Time: 19:03
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui.form小例子</title>
</head>
<!-- 引入 layui.css -->
<link rel="stylesheet" href="//unpkg.com/layui@2.6.8/dist/css/layui.css"/>
<style>

    select {
        float: right;
    }
</style>
<body>

<div class="yyds">

    <form class="layui-form" action="${pageContext.request.contextPath}/findLikeStudentNameOrStudentNumServlet" method="post"> <!-- 提示：如果你不想用form，你可以换成div等任何一个普通元素 -->
        <!-- 更多表单结构排版请移步文档左侧【页面元素-表单】一项阅览 -->

        <table class="layui-table">
            <colgroup>
                <col width="400">
                <col width="400">
                <col>
            </colgroup>
            <thead>
            <tr>
                <th>
                    <label class="layui-form-label">请输入</label>
                    <div class="layui-input-block">
                        <input type="text" name="StudentNumberAndName" placeholder="请输入学号或者姓名" autocomplete="off" class="layui-input">
                    </div>
                </th>
                <th>
                    <label class="layui-form-label">下拉选择框</label>
                    <div class="layui-input-block">
                        <select name="studentIsin" lay-filter="aihao">
                            <option value="0">已入住</option>
                            <option value="1">没入住</option>
                            <option value="2">迁出</option>
                        </select>
                    </div>
                </th>
                <th>
                    &nbsp;&nbsp;&nbsp;&nbsp;<button type="submit" class="layui-btn">确认查询</button>
                </th>
                <th>
                    &nbsp;&nbsp;&nbsp;&nbsp;<button type="button" class="layui-btn" onclick="toInsertStudent()">添加学生信息
                </button>
                </th>
            </tr>
            </thead>
        </table>
    </form>

</div>

<table class="layui-table">
    <colgroup>
        <col width="150">
        <col width="150">
        <col width="150">
        <col width="150">
        <col width="150">
        <col width="180">
        <col width="230">
        <col width="240">
        <col>
    </colgroup>
    <thead>
    <tr>
        <th>学号</th>
        <th>姓名</th>
        <th>性别</th>
        <th>入住信息</th>
        <th>手机号码</th>
        <th>楼宇信息</th>
        <th>备注</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach items="${studentsList}" var="student">
        <tr>
            <td>${student.studentNum}</td>
            <td>${student.studentName}</td>
            <td>
                <c:if test="${student.studentSex eq 0}">男</c:if>
                <c:if test="${student.studentSex eq 1}">男</c:if>
            </td>
            <td><c:if test="${student.studentIsin eq 0}">未入住</c:if>
                <c:if test="${student.studentIsin eq 1})">已入住</c:if>
                <c:if test="${student.studentIsin eq 2}">已迁出</c:if>
            </td>
            <td>${student.studentPhone}</td>
            <td>${student.studentBuild}</td>
            <td>${student.studentInfo}</td>
            <td>
                &nbsp;&nbsp;<button type="button" class="layui-btn layui-btn-radius layui-btn-normal">编辑</button>&nbsp;&nbsp;
                <button type="button" class="layui-btn layui-btn-radius layui-btn-danger"
                        onclick="deleteOne(${student.studentId})">删除
                </button>
            </td>
        </tr>
    </c:forEach>

    </tbody>
</table>
<script src="//unpkg.com/layui@2.6.8/dist/layui.js"/>
<script>
    layui.use('form', function () {
        var form = layui.form;
        //各种基于事件的操作，下面会有进一步介绍
    });

</script>
<script>
    function toInsertStudent() {
        window.location.href = "pages/insertStudent.jsp"
    }

    function deleteOne(obj) {
        // alert(obj)
        if (confirm("你确定要删除吗？")) {
            window.location.href = "deleteOneServlet?studentId=" + obj
        } else {
            return false
        }
    }

</script>
</body>
</html>